// enum like for pages names
var Pages = {
	HOME : "home", VIEWITEM : "viewItem", REGISTER : "register" ,SEARCH : "search" 	,
	POSTITEM : "postItem"
};
//stores the current page name
var currentPage = Pages.HOME;
var nestedPage;

function returnToHome(){
	getNestedPage().removeAttribute("src"); 
	currentPage = Pages.HOME;
	updateItemsDetails();
	fillNewItems();
	emptyCachedItems();
	startRefreshingBids();
	startRefreshingItems();
	startRefreshingStatistics();
	emptyCachedItems();
}

function switchToRegister(){
	extendPage();
	getNestedPage().setAttribute("src","register.html");
	currentPage = Pages.REGISTER;
	removeHome();
}

function switchToPostItem(){
	extendPage();
	getNestedPage().setAttribute("src","newitem.html");
	currentPage = Pages.POSTITEM;
	removeHome();
}

function switchToViewItem(){
	extendPage();
	getNestedPage().setAttribute("src","viewitem.html");
	currentPage = Pages.VIEWITEM;
	removeHome();
}

function switchToSearch(){
	extendPage();
	getNestedPage().setAttribute("src","search.html");
	currentPage = Pages.SEARCH;
	removeHome();
}

function getNestedPage(){
	if(nestedPage == null)
		nestedPage = document.getElementById("nestedpage");
	return nestedPage;
}

function extendPage(){
	getNestedPage().style.height = 800;
	getNestedPage().style.width = 500;
}

function removeHome(){
			document.getElementById("newitems").innerHTML = "";
			document.getElementById("bids").innerHTML = "";
			startRefreshingBids();
			startRefreshingItems();
			startRefreshingStatistics();
}